//
//  XQIdentityErrorView.m
//  JoinPeso
//
//  Created by 小琦 on 2024/11/23.
//

#import "XQIdentityErrorView.h"

@interface XQIdentityErrorView()
@property (nonatomic,strong) UILabel *titleLb;
@property (nonatomic,strong) UIView *contentView;
@property (nonatomic,strong) UIImageView *imageView1;
@property (nonatomic,strong) UIImageView *imageView2;
@property (nonatomic,strong) UIImageView *imageView3;
@property (nonatomic,strong) UIView *view1;
@property (nonatomic,strong) UIView *view2;
@property (nonatomic,strong) UIView *view3;
@property (nonatomic,strong) UILabel *label1;
@property (nonatomic,strong) UILabel *label2;
@property (nonatomic,strong) UILabel *label3;
@end

@implementation XQIdentityErrorView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self makeUI];
        [self makeConstraints];
    }
    return self;
}

- (void)makeUI {
    [self addSubview:self.titleLb];
    [self addSubview:self.contentView];
    [self.contentView addSubview:self.imageView1];
    [self.contentView addSubview:self.imageView2];
    [self.contentView addSubview:self.imageView3];
    [self.imageView1 addSubview:self.view1];
    [self.imageView2 addSubview:self.view2];
    [self.imageView3 addSubview:self.view3];
    [self.view1 addSubview:self.label1];
    [self.view2 addSubview:self.label2];
    [self.view3 addSubview:self.label3];
}

- (void)makeConstraints {
    
    CGFloat imageW = ([UIScreen mainScreen].width - 21 * 2 - 16 * 2) / 3;
    
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@0);
        make.left.equalTo(@12);
        make.height.mas_equalTo(22);
    }];
    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@12);
        make.right.equalTo(@-12);
        make.top.equalTo(self.titleLb.mas_bottom).offset(10);
        make.height.mas_equalTo(150);
        make.bottom.equalTo(@0);
    }];
    [self.imageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@9);
        make.width.mas_equalTo(imageW);
        make.top.equalTo(@27);
        make.bottom.equalTo(@-25);
    }];
    [self.imageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageView1.mas_right).offset(16);
        make.width.mas_equalTo(imageW);
        make.top.equalTo(@27);
        make.bottom.equalTo(@-25);
    }];
    [self.imageView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.imageView2.mas_right).offset(16);
        make.width.mas_equalTo(imageW);
        make.top.equalTo(@27);
        make.bottom.equalTo(@-25);
    }];
    [self.view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(@0);
        make.height.mas_equalTo(36);
    }];
    [self.view2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(@0);
        make.height.mas_equalTo(36);
    }];
    [self.view3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.equalTo(@0);
        make.height.mas_equalTo(36);
    }];
    [self.label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        (void)make.center;
    }];
    [self.label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        (void)make.center;
    }];
    [self.label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        (void)make.center;
    }];
}

#pragma mark - setter

- (void)setImages:(NSArray *)images {
    self.imageView1.image = [UIImage imageNamed:images[0]];
    self.imageView2.image = [UIImage imageNamed:images[1]];
    self.imageView3.image = [UIImage imageNamed:images[2]];
}

- (void)setTexts:(NSArray *)texts {
    self.label1.text = texts[0];
    self.label2.text = texts[1];
    self.label3.text = texts[2];
}

#pragma mark - lazy

- (UILabel *)titleLb {
    if (!_titleLb) {
        _titleLb = [[UILabel alloc] init];
        _titleLb.textColor = kBlackTextColor;
        _titleLb.font = [UIFont boldSystemFontOfSize:16];
        _titleLb.text = @"Wrong demonstration";
    }
    return _titleLb;
}

- (UIView *)contentView {
    if (!_contentView) {
        _contentView = [[UIView alloc] init];
        _contentView.backgroundColor = [UIColor whiteColor];
        _contentView.layer.cornerRadius = 20;
    }
    return _contentView;
}

- (UIImageView *)imageView1 {
    if (!_imageView1) {
        _imageView1 = [[UIImageView alloc] init];
    }
    return _imageView1;
}

- (UIImageView *)imageView2 {
    if (!_imageView2) {
        _imageView2 = [[UIImageView alloc] init];
    }
    return _imageView2;
}

- (UIImageView *)imageView3 {
    if (!_imageView3) {
        _imageView3 = [[UIImageView alloc] init];
    }
    return _imageView3;
}

- (UIView *)view1 {
    if (!_view1) {
        _view1 = [[UIView alloc] init];
    }
    return _view1;
}

- (UIView *)view2 {
    if (!_view2) {
        _view2 = [[UIView alloc] init];
    }
    return _view2;
}

- (UIView *)view3 {
    if (!_view3) {
        _view3 = [[UIView alloc] init];
    }
    return _view3;
}

- (UILabel *)label1 {
    if (!_label1) {
        _label1 = [[UILabel alloc] init];
        _label1.textColor = [UIColor whiteColor];
        _label1.font = [UIFont systemFontOfSize:14];
        _label1.numberOfLines = 0;
        _label1.textAlignment = NSTextAlignmentCenter;
    }
    return _label1;
}

- (UILabel *)label2 {
    if (!_label2) {
        _label2 = [[UILabel alloc] init];
        _label2.textColor = [UIColor whiteColor];
        _label2.font = [UIFont systemFontOfSize:14];
        _label2.numberOfLines = 0;
        _label2.textAlignment = NSTextAlignmentCenter;
    }
    return _label2;
}

- (UILabel *)label3 {
    if (!_label3) {
        _label3 = [[UILabel alloc] init];
        _label3.textColor = [UIColor whiteColor];
        _label3.font = [UIFont systemFontOfSize:14];
        _label3.numberOfLines = 0;
        _label3.textAlignment = NSTextAlignmentCenter;
    }
    return _label3;
}

@end
